package com.tuanda.app.customviewdemo.cavans;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by LiDongduo on 2018/9/19.
 */
public class DrawCircleView extends View {

    private Paint mPaint;

    public DrawCircleView(Context context) {
        this(context,null);
    }

    public DrawCircleView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public DrawCircleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        // 初始化 开启抗锯齿
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        // 设置颜色
        mPaint.setColor(Color.BLUE);
        // 设置 是否为空心
        mPaint.setStyle(Paint.Style.FILL);
        // 如果为空心设置线条宽度
//        mPaint.setStrokeWidth(10);
        // 动态开启抗锯齿
//        mPaint.setAntiAlias(true);
        // 设置线条两端的形状
//        mPaint.setStrokeCap(Paint.Cap.BUTT);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawColor(Color.parseColor("#88880000"));
        canvas.drawCircle(70,70,40,mPaint);
    }
}
